package cn.yitun.chat.yitunservermaincoresingle.main.common.auth.box;

import cn.yitun.chat.yitunserverimcore.bridge.main.common.auth.box.AuthBox;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * Date 2019-04-20 09:18:33<br>
 * Description
 * 
 * @author yitun
 * @since 1.0.0
 */
@Component
public class AuthBoxImpl implements AuthBox {

	private Map<String, Long> map = new ConcurrentSkipListMap<>();

	@Override
	public void put(String token, Long userId) {
		map.put(token, userId);
	}

	@Override
	public Long getUserId(String token) {
		token = (null == token) ? "" : token;
		return map.get(token);
	}

	@Override
	public Long remove(String token) {
		token = (null == token) ? "" : token;
		return map.remove(token);
	}
}
